---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: deschedulers.deckhouse.io
spec:
  group: deckhouse.io
  names:
    kind: Descheduler
    listKind: DeschedulerList
    plural: deschedulers
    singular: descheduler
  scope: Cluster
  versions:
    - additionalPrinterColumns:
        - jsonPath: .status.ready
          name: Ready
          type: boolean
      name: v1alpha1
      schema:
        openAPIV3Schema:
          description: Descheduler is a description of a single descheduler instance.
          properties:
            apiVersion:
              type: string
            kind:
              type: string
            metadata:
              type: object
              properties:
                name:
                  type: string
            spec:
              description: Defines the behavior of a descheduler instance.
              properties:
                deploymentTemplate:
                  description: Defines Template of a descheduler Deployment.
                  properties:
                    nodeSelector:
                      additionalProperties:
                        type: string
                      type: object
                    tolerations:
                      items:
                        properties:
                          effect:
                            type: string
                          key:
                            type: string
                          operator:
                            type: string
                          tolerationSeconds:
                            format: int64
                            type: integer
                          value:
                            type: string
                        type: object
                      type: array
                  type: object
                deschedulerPolicy:
                  description: |
                    `globalParameters` and `strategies` follow the [descheduler's documentation](https://github.com/kubernetes-sigs/descheduler#policy-and-strategies).
                  properties:
                    globalParameters:
                      description: Parameters that apply to all policies.
                      properties:
                        evictFailedBarePods:
                          description: Allows Pods without `ownerReferences` and in `failed` phase to be evicted.
                          type: boolean
                        evictLocalStoragePods:
                          description: Allows Pods using local storage to be evicted.
                          type: boolean
                        evictSystemCriticalPods:
                          description: Allows eviction of Pods of any priority (including Kubernetes system Pods).
                          type: boolean
                        ignorePvcPods:
                          description: Prevents Pods with PVCs from being evicted.
                          type: boolean
                        maxNoOfPodsToEvictPerNamespace:
                          description: Restricts maximum of Pods to be evicted per namespace.
                          type: integer
                        maxNoOfPodsToEvictPerNode:
                          description: Restricts maximum of Pods to be evicted per node.
                          type: integer
                        nodeSelector:
                          type: string
                      type: object
                    strategies:
                      description: List of strategies with corresponding parameters for a given Descheduler instances.
                      properties:
                        highNodeUtilization:
                          required: [enabled]
                          description: >
                            This strategy finds nodes that are under utilized and evicts Pods from the nodes in the hope
                            that these Pods will be scheduled compactly into fewer nodes.
                          properties:
                            enabled:
                              type: boolean
                            nodeFilter: &node-filter
                              description: Filters Nodes to which the strategy applies.
                              labelSelector:
                                properties:
                                  matchExpressions:
                                    type: array
                                    description: List of label expressions that a node should have to qualify for the filter condition.
                                    items:
                                      properties:
                                        key:
                                          type: string
                                          description: A label name.
                                        operator:
                                          type: string
                                          description: A comparison operator.
                                          enum:
                                            - In
                                            - NotIn
                                            - Exists
                                            - DoesNotExist
                                        values:
                                          type: array
                                          description: A label value.
                                          items:
                                            type: string
                                            pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?'
                                            minLength: 1
                                            maxLength: 63
                                      oneOf:
                                        - properties:
                                            operator:
                                              enum: [ Exists, DoesNotExist ]
                                          required: [ key, operator ]
                                          not:
                                            required: [ values ]
                                        - properties:
                                            operator:
                                              enum: [ In, NotIn ]
                                          required: [ key, operator, values ]
                                      type: object
                                    x-doc-examples:
                                      - - key: tier
                                          operator: In
                                          values:
                                            - production
                                            - staging
                                        - key: tier
                                          operator: NotIn
                                          values: [ production ]
                                  matchLabels:
                                    additionalProperties:
                                      type: string
                                    type: object
                                type: object
                              type: object
                            priorityFilter: &priority-filter
                              description: Only Pods with priority lower than this will be descheduled.
                              thresholdPriority:
                                format: int32
                                type: integer
                              thresholdPriorityClassName:
                                type: string
                              type: object
                            namespaceFilter: &namespace-filter
                              description: Restricts Namespaces to which this strategy applies.
                              namespaces:
                                properties:
                                  exclude:
                                    items:
                                      type: string
                                    type: array
                                  include:
                                    items:
                                      type: string
                                    type: array
                                type: object
                              type: object
                            nodeFit: &node-fit
                              description: >
                                If set to true, the descheduler will consider whether or not the Pods
                                that meet eviction criteria will fit on other nodes before evicting them.
                              type: boolean
                          type: object
                        lowNodeUtilization:
                          required: [enabled]
                          description: >
                            This strategy finds nodes that are under utilized and evicts Pods, if possible, from other nodes in the hope
                            that recreation of evicted Pods will be scheduled on these underutilized nodes.
                          properties:
                            enabled:
                              type: boolean
                            nodeFilter: *node-filter
                            priorityFilter: *priority-filter
                            namespaceFilter: *namespace-filter
                            nodeFit: *node-fit
                          type: object
                        removeDuplicates:
                          required: [enabled]
                          description: >
                            This strategy makes sure that there is only one Pod associated with
                            a ReplicaSet (RS), ReplicationController (RC), StatefulSet, or Job running on the same node.
                          properties:
                            enabled:
                              type: boolean
                            nodeFilter: *node-filter
                            priorityFilter: *priority-filter
                            namespaceFilter: *namespace-filter
                            nodeFit: *node-fit
                          type: object
                        removeFailedPods:
                          required: [enabled]
                          description: This strategy evicts Pods that are in failed status phase.
                          properties:
                            enabled:
                              type: boolean
                            nodeFilter: *node-filter
                            priorityFilter: *priority-filter
                            namespaceFilter: *namespace-filter
                            nodeFit: *node-fit
                          type: object
                        removePodsHavingTooManyRestarts:
                          required: [enabled]
                          description: This strategy makes sure that Pods having too many restarts are removed from nodes.
                          properties:
                            enabled:
                              type: boolean
                            nodeFilter: *node-filter
                            priorityFilter: *priority-filter
                            namespaceFilter: *namespace-filter
                            nodeFit: *node-fit
                          type: object
                        removePodsViolatingInterPodAntiAffinity:
                          required: [enabled]
                          description: This strategy makes sure that Pods violating interpod anti-affinity are removed from nodes.
                          properties:
                            enabled:
                              type: boolean
                            nodeFilter: *node-filter
                            priorityFilter: *priority-filter
                            namespaceFilter: *namespace-filter
                            nodeFit: *node-fit
                          type: object
                        removePodsViolatingNodeAffinity:
                          required: [enabled]
                          description: This strategy makes sure all Pods violating node affinity are eventually removed from nodes.
                          properties:
                            enabled:
                              type: boolean
                            nodeFilter: *node-filter
                            priorityFilter: *priority-filter
                            namespaceFilter: *namespace-filter
                            nodeFit: *node-fit
                          type: object
                        removePodsViolatingNodeTaints:
                          required: [enabled]
                          description: This strategy makes sure that Pods violating NoSchedule taints on nodes are removed.
                          properties:
                            enabled:
                              type: boolean
                            nodeFilter: *node-filter
                            priorityFilter: *priority-filter
                            namespaceFilter: *namespace-filter
                            nodeFit: *node-fit
                          type: object
                        removePodsViolatingTopologySpreadConstraint:
                          required: [enabled]
                          description: This strategy makes sure that Pods violating topology spread constraints are evicted from nodes.
                          properties:
                            enabled:
                              type: boolean
                            nodeFilter: *node-filter
                            priorityFilter: *priority-filter
                            namespaceFilter: *namespace-filter
                            nodeFit: *node-fit
                          type: object
                      type: object
                  type: object
              type: object
            status:
              description: Most recently observed status of a descheduler instance.
              properties:
                ready:
                  type: boolean
              required:
                - ready
              type: object
          required:
            - spec
          type: object
      served: true
      storage: true
      subresources:
        status: {}
